package com.fy.oa.zc.menu.manager;

import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.JdbcTemplate;

public final class FyReport_AuditTimeManagerImpl implements FyReport_AuditTimeManager {
	private JdbcTemplate jdbcTemplate;
	private String queryDealTimeSql = "select a.SUBJECT,pd.NAME account,cd.NAME depName,m.NAME||'('||m.CODE||')' member,to_char(a.RECEIVE_TIME,'yyyy-mm-dd hh24:mi:ss') RECEIVETIME,decode(a.COMPLETE_TIME,'','未处理',to_char(a.COMPLETE_TIME,'yyyy-mm-dd hh24:mi:ss')) COMPLETETIME,"
			+ "ZC_TIMECAL(to_char(a.RECEIVE_TIME,'yyyy-mm-dd hh24:mi:ss'),to_char(decode(a.COMPLETE_TIME,'',sysdate,a.COMPLETE_TIME),'yyyy-mm-dd hh24:mi:ss')) dealTime\n"
			+ "from CTP_AFFAIR a left join ORG_MEMBER m on a.MEMBER_ID = m.ID\n"
			+ "left join ORG_UNIT cd on cd.id = m.ORG_DEPARTMENT_ID\n"
			+ "left join ORG_UNIT pd on substr(cd.PATH,0,8) = pd.PATH\n"
			+ "where m.ORG_ACCOUNT_ID = ? and a.RECEIVE_TIME >= to_date(?,'yyyy-mm-dd hh24:mi:ss') and a.RECEIVE_TIME <= to_date(?,'yyyy-mm-dd hh24:mi:ss') and a.STATE in (3,4) and a.NODE_POLICY is not null and a.NODE_POLICY <>'inform'\n"
			+ "and cd.IS_ENABLE = 1 and cd.IS_DELETED = 0 and pd.IS_ENABLE = 1 and pd.IS_DELETED = 0 and pd.NAME not in ('董事会','总裁办')\n"
			+ "and a.FORM_APP_ID is not null";

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	@Override
	public List<Map<String, Object>> queryDealTime(String startDate, String endDate, long accountID) {
		System.out.println("************\n"+queryDealTimeSql+"\n************\n");
		return jdbcTemplate.queryForList(queryDealTimeSql, accountID, startDate, endDate);
	}
}
